<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * 励志2+4活动字典表
 *
 * @author wutian
 */

namespace Home\Model ;

class ActivityDictionaryModel extends \Think\Model
{

    /**
     * 添加活动相应信息
     * @param type $ActivityName
     * @param type $ActivityOrganization
     * @param type $ActivityTimeStart
     * @param type $ActivityTimeEnd
     * @param type $ActivityHours
     * @param type $ResponsiblePerson
     * @param type $ResponsiblePersonTelephone
     * @return boolean
     */
    function addActivityInfor ( $ActivityName , $ActivityOrganization ,
            $ActivityTimeStart , $ActivityTimeEnd , $ActivityHours ,
            $ResponsiblePersonName , $ResponsiblePersonTelephone ,
            $ActivityResult )
    {
        $map[ 'ActivityName' ]               = $ActivityName ;
        $map[ 'ActivityOrganization' ]       = $ActivityOrganization ;
        $map[ 'ActivityTimeStart' ]          = $ActivityTimeStart ;
        $map[ 'ActivityTimeEnd' ]            = $ActivityTimeEnd ;
        $map[ 'ActivityHours' ]              = $ActivityHours ;
        $map[ 'ResponsiblePersonName' ]      = $ResponsiblePersonName ;
        $map[ 'ResponsiblePersonTelephone' ] = $ResponsiblePersonTelephone ;
        $map[ 'ActivityResult' ]             = $ActivityResult ;
        if ( $this->create ( $map ) )
        {
            if ( ! $this->add () )
            {
                return false ;
            }
            return true ;
        }
        return false ;
    }

    /**
     * 通过活动编号查询活动信息
     * @param array $ActivityIDArray
     * @return type
     */
    function getActivityInforByActivityID ( $ActivityIDArray , $Year )
    {
        $map[ 'ActivityID' ] = array ( 'in' , $ActivityIDArray ) ;
        if ( $Year == null )
        {
            $map[ 'ActivityTimeStart' ] = array ( 'egt' , $Year . '-00-00' ) ; //大于等于
        }
        else
        {
            $map[ 'ActivityTimeStart' ] = array ( 'between' , array ( $Year . '0000' ,
                    $Year . '1231' ) ) ;
        }
        $rs = $this->where ( $map )->select () ;
        return $rs ? $rs : false ;
    }

}
